package com.serverGroup.baseModule.service.impl;

import org.springframework.stereotype.Service;

import com.serverGroup.base.BaseService;
import com.serverGroup.baseModule.bean.UserBean;
import com.serverGroup.baseModule.dao.UserDao;
import com.serverGroup.baseModule.service.UserService;

/**  
* @Title: UserServiceImpl
* @Description:   实现了代理的基础接口和用户表的操作service接口
* @author Hr222  
* @date 2018年8月26日  
*/  
@Service("userService")
public class UserServiceImpl extends BaseService<UserDao, UserBean> implements UserService {

	@Override
	public int addUser(UserBean user) {
		// TODO Auto-generated method stub
		try {
			int id = baseDao.add(user);
			return id;
		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return 0;
	}

	@Override
	public UserBean queryById(int id) {
		// TODO Auto-generated method stub
		try {
			UserBean user = baseDao.queryById(id);
			return user;
		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public void updateUser(UserBean user) {
		// TODO Auto-generated method stub
		try {
			baseDao.update(user);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

	@Override
	public void deleteById(int userId) {
		// TODO Auto-generated method stub
		try {
			baseDao.deleteById(userId);
		}catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public UserBean userLogin(String username) {
		try {
			UserBean user = baseDao.login(username);
			if (user != null) {
				return user;
			}
		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return null;
	}
	
}
